package kr.or.smardi.smardi_AScan.Help;
import kr.or.smardi.smardi_AScan.*;
import kr.or.smardi.smardi_AScan.Record.*;
import kr.or.smardi.smardi_AScan.Scan.*;
import kr.or.smardi.smardi_AScan.User.*;
import kr.or.smardi.smardi_AScan.db.*;
import android.app.*;
import android.content.*;
import android.graphics.*;
import android.os.*;
import android.view.*;
import android.widget.*;

public class AC_Help_main extends Activity {

	TextView txt_setting_1, txt_setting_2, txt_setting_3;
	CheckBox cbox_location;
	
	RelativeLayout btn_setting_1, btn_setting_2, btn_setting_3;
	
	Manage_SharedPreference mPref = null;
	
	RelativeLayout titleBar = null;
	ImageButton btn_TopLeft = null;
	ImageButton btn_TopRight = null;
	TextView txt_subTitle = null;

	// 탭 메뉴
	LinearLayout tabMenu = null;
	ImageButton tab_measure = null;
	ImageButton tab_record = null;
	ImageButton tab_user = null;
	ImageButton tab_help = null;
	
	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ac_help_main);

		initComponent();

	}

	private void initComponent() {
		
		mPref = new Manage_SharedPreference(AC_Help_main.this);
		
		txt_subTitle = (TextView) findViewById(R.id.txt_subTitle);
		txt_setting_1 = (TextView) findViewById(R.id.txt_setting1);
		txt_setting_2 = (TextView) findViewById(R.id.txt_setting2);
		txt_setting_3 = (TextView) findViewById(R.id.txt_setting3);

		
		
		titleBar = (RelativeLayout) findViewById(R.id.inc_title_bar);
		btn_TopLeft = (ImageButton) titleBar.findViewById(R.id.btn_top_left);
		btn_TopLeft.setImageDrawable(getResources().getDrawable(
				R.drawable.c_btn_back));
		btn_TopLeft.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				goBack();
			}
		});
		btn_TopRight = (ImageButton) titleBar.findViewById(R.id.btn_top_right);
		btn_TopRight.setVisibility(View.GONE);
		txt_subTitle = (TextView) findViewById(R.id.txt_subTitle);
		txt_subTitle.setText(getString(R.string.subTitle_help_main));

		// 탭 세팅--------------------------
		tabMenu = (LinearLayout) findViewById(R.id.inc_tab_menu);
		tab_measure = (ImageButton) findViewById(R.id.tab_measure);
		tab_record = (ImageButton) findViewById(R.id.tab_record);
		tab_user = (ImageButton) findViewById(R.id.tab_user);
		tab_help = (ImageButton) findViewById(R.id.tab_help);
		tab_help.setImageDrawable(getResources().getDrawable(
				R.drawable.tab_help_1));

		tab_record.setOnClickListener(onClickListener);
		tab_user.setOnClickListener(onClickListener);
		tab_measure.setOnClickListener(onClickListener);
		// 탭 세팅 끝--------------------------
		
		btn_setting_1 = (RelativeLayout) findViewById(R.id.btn_setting_1);
		registOnClickEvent(btn_setting_1);
		
		if(getString(R.string.language).equals("en")) {
			btn_setting_1.setVisibility(View.GONE);
		}
		
		btn_setting_2 = (RelativeLayout) findViewById(R.id.btn_setting_2);
		registOnClickEvent(btn_setting_2);
		
		btn_setting_3 = (RelativeLayout) findViewById(R.id.btn_setting_3);
		registOnClickEvent(btn_setting_3);
		
		
		changeFont();
	}

	private void registOnClickEvent(View v) {
		v.setOnClickListener(onClickListener);
	}

	private void changeFont() {
		// Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/MuseoSans_700.otf");
		Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/Daum_Regular.ttf");

		txt_subTitle.setTypeface(tf);

		txt_setting_1.setTypeface(tf);
		txt_setting_2.setTypeface(tf);
		txt_setting_3.setTypeface(tf);
	}

	
	View.OnClickListener onClickListener = new View.OnClickListener() {
		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.btn_top_left:
				goBack();
				break;
			//--------------------------------------------------------
			case R.id.tab_measure:
				goBack();
				break;
			case R.id.tab_record:
				goRecord();
				break;
			case R.id.tab_user:
				goUser();
				break;
			//--------------------------------------------------------
			case R.id.btn_setting_1:
				startActivity(new Intent(AC_Help_main.this, AC_Help_tip.class));
				finish();
				break;
			case R.id.btn_setting_2:
				startActivity(new Intent(AC_Help_main.this, AC_Help_tutorial.class));
				break;
			case R.id.btn_setting_3:
				popupAbout();
				break;
			}
		}
	};
	
	
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {

		switch (keyCode) {
		case KeyEvent.KEYCODE_BACK:

			goBack();
			return false;
		}

		return super.onKeyDown(keyCode, event);
	}
	
	/**
	 * 이전 화면(빠른측정/정밀측정 선택화면)으로 이동한다
	 */
	private void goBack() {
		Intent intent = new Intent(AC_Help_main.this, AC_Scan_main.class);
		startActivity(intent);
		finish();
		overridePendingTransition(R.anim.fadein, R.anim.fadeout);
	}
	
	private void goRecord() {
		Intent intent = new Intent(AC_Help_main.this, AC_RecordMain.class);
		startActivity(intent);
		finish();
		overridePendingTransition(R.anim.fadein, R.anim.fadeout);
	}
	
	private void goUser() {
		Intent intent = new Intent(AC_Help_main.this, AC_UserMain.class);
		startActivity(intent);
		finish();
		overridePendingTransition(R.anim.fadein, R.anim.fadeout);
	}

	
	private void popupAbout() {
		Intent intent = new Intent(AC_Help_main.this, AC_About.class);
		startActivity(intent);
	}
}
